<template>
  <div>
    <!-- 头部 -->
    <van-nav-bar title="暂无回复" left-arrow @click-left="$emit('close')" />
    <!-- 内容 -->
    <van-cell class="comment-info">
      <template #icon>
        <van-image
          :src="ReplyComment.aut_photo"
          round
          fit="cover"
          class="avatar"
        />
      </template>
      <template #title>
        <div class="user-name">{{ ReplyComment.aut_name }}</div>
        <div class="content">{{ ReplyComment.content }}</div>
        <div class="desc">
          <span class="pubdate">{{ label(ReplyComment) }}</span>
          <van-button round size="small" @click="replyComment(ReplyComment)">
            回复 {{ ReplyComment.reply_count }}
          </van-button>
        </div>
      </template>
      <div><van-icon name="good-job-o" />赞</div>
    </van-cell>
    <!-- 分割符 -->
    <van-divider>全部回复</van-divider>
    <!-- 评论回复内容 -->
    <comments-list
      type="c"
      :source="ReplyComment.com_id"
      :newComment="newComment"
      @showReplyCommentPopup="showReplyComment"
    ></comments-list>
    <!-- 发布评论 -->
    <van-button
      class="post-comment-btn"
      type="default"
      block
      @click="isShowComments = true"
    >
      发布评论
    </van-button>
    <!-- 发布评论弹出层 -->
    <van-popup
      v-model="isShowComments"
      position="bottom"
      class="comments-popup"
    >
      <comment-post
        :target="ReplyComment.com_id"
        :art_id="$route.query.articleId"
        @commentPost=";[(isShowComments = false), (newComment = $event)]"
      ></comment-post>
    </van-popup>
  </div>
</template>

<script>
import dayjs from '@/utils/dayjs'
import CommentPost from './CommentPost.vue'
import CommentsList from './CommentsList.vue'
export default {
  name: '',
  components: { CommentPost, CommentsList },
  props: {
    ReplyComment: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      isShowComments: false,
      newComment: {}
    }
  },
  computed: {
    label() {
      return function (comment) {
        return dayjs(comment.pubdate).fromNow()
      }
    }
  },
  watch: {},
  created() {},
  methods: {
    // 展开回复评论
    showReplyComment() {
      this.isShowReplyComment = true
    }
  }
}
</script>

<style scoped lang="less">
.post-comment-btn {
  position: fixed;
  bottom: 0;
  left: 0;
  background-color: #fff;
  color: #666;
}
.comments-popup {
  height: 18%;
}
.comment-info {
  padding: 0.26667rem 0.42667rem;
  .avatar {
    width: 0.93333rem;
    height: 0.93333rem;
    margin-right: 0.22667rem;
  }
  .user-name {
    font-size: 0.37333rem;
    line-height: 0.64rem;
    color: #466b9d;
  }
  .content {
    margin-top: 0;
    margin-bottom: 0.42667rem;
    color: #363636;
    font-size: 0.32rem;
    line-height: 0.48rem;
    margin-top: 0.1rem;
  }
  .desc {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 4rem;
    margin-bottom: 0.42667rem;
    .pubdate {
      margin-right: 10px;
      font-size: 0.32rem;
      color: #969799;
    }
    .van-button {
      width: 2.2rem;
      height: 0.64rem;
      line-height: 0.64rem;
      font-size: 0.28rem;
      color: #222;
    }
  }
}
</style>
